from django.db import models

# Create your models here.
class Unit(models.Model):
    name = models.CharField(max_length=30)
    member_count = models.SmallIntegerField()
    style = models.CharField(max_length=20)
    pos_x = models.IntegerField(null=True)
    pos_y = models.IntegerField(null=True)
    max_priority = models.SmallIntegerField(default=0)
    max_done_priority = models.SmallIntegerField(default=0)
    
    def __unicode__(self):
        return "[name=" + self.name \
                + ", member_count=" + self.member_count.__str__() \
                + "]"


class Task(models.Model):
    name = models.CharField(max_length=100)
    content = models.TextField(null=True)
    icon = models.CharField(max_length=20)
    owner = models.ForeignKey(Unit)
    duration = models.IntegerField()
    priority = models.IntegerField()
    finish_date = models.DateField(null=True)
    deleted = models.BooleanField(default=False)
    
    def __unicode__(self):
        return "[name=" + self.name \
                + ", owner=" + self.owner.__str__() \
                + ", duration=" + self.duration.__str__() \
                + "]"
    
    
class Project(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField(null=True)
    start_date = models.DateField()
    end_date = models.DateField()
    member_count = models.SmallIntegerField()
    
    def __unicode__(self):
        return "[name=" + self.name \
                + ", start_date=" + self.start_date.__str__() \
                + ", end_date=" + self.end_date.__str__() \
                + ", member_count=" + self.member_count.__str__() \
                + "]"
